import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBColor/YBColor.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBImageStyle/YBImageStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBJsonToModel/YBWorkTaiModel/YBGongGongCreateTimeModel.dart';

import 'YBMiShuProvider/YBMiShuProvider.dart';
import 'YBMiShuSubPage/YBMiShuTongListDetailSubPage.dart';

class YBYiJiLvSiYiHuoDetailPage extends StatelessWidget {

  final String sysCode;
  final String requestCode;

  const YBYiJiLvSiYiHuoDetailPage({Key key, this.sysCode, this.requestCode}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Scaffold(
        appBar: AppBar(
          elevation: 0,
          title: Text(
            YBChineseText.workTaiShangJiDetailTitle,
            style: YBTextStyle.TextStyle30313320Medium
          ),
        ),
        body:MultiProvider(
          providers:[
            ChangeNotifierProvider(create:(context)=>YBYIJiTonglvsiTongYouXuanDetailProvider()..getGongGongYouXuanDataList(sysCode, requestCode)),
          ],
          child: Consumer<YBYIJiTonglvsiTongYouXuanDetailProvider>(
              builder:(context,yihuoData,child){
                String createTimeStr;
                if (yihuoData.gongGongYouXuanModel.requestAssignRecordList != null) {
                  YBGongGongCreateTimeModel createTimeModel = yihuoData.gongGongYouXuanModel.requestAssignRecordList.last;
                  createTimeStr = createTimeModel.createTime;
                }
                return Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: [
                    Expanded(
                      child:CustomScrollView(
                        slivers: <Widget>[
                          SliverToBoxAdapter(
                            child: Container(
                              child: Column(
                                children: [
                                  Container(
                                    color:YBColor.white,
                                    child: Padding(
                                      padding: EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20),
                                      child: Column(
                                        children: [
                                          Container(
                                            height: YBTextStyle.adapterSize20,
                                          ),
                                          Container(
                                            child: Row(
                                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                              crossAxisAlignment: CrossAxisAlignment.center,
                                              children: [
                                                Container(
                                                  child: Text(
                                                    createTimeStr??"",
                                                    style: YBTextStyle.TextStyle1B1C1F15Medium,
                                                  ),
                                                ),
                                                Container(
                                                  child: Text(
                                                    "${yihuoData.gongGongYouXuanModel.request.provinceName}-${yihuoData.gongGongYouXuanModel.request.cityName}"??"",
                                                    style: YBTextStyle.TextStyle6E737A13,
                                                  ),
                                                ),
                                              ],
                                            ),
                                          ),
                                          Container(
                                            height: YBTextStyle.adapterSize16,
                                          ),
                                          Container(
                                            child: Row(
                                              children: [
                                                Container(
                                                  child: Image.asset(YBImageStyle.getImagePath('BLBBusinessOppoManager_phonr')),
                                                ),
                                                Container(
                                                  width: 5,
                                                ),
                                                Container(
                                                  child: Text(
                                                    yihuoData.gongGongYouXuanModel.linkPhone??'',
                                                    style: YBTextStyle.TextStyle6E737A13,
                                                  ),
                                                ),
                                              ],
                                            ),
                                          ),
                                          Container(
                                            height: YBTextStyle.adapterSize16,
                                          ),
                                        ],
                                      ),
                                    ),
                                  ),
                                  Container(
                                    height: 8,
                                  ),
                                  Container(
                                    color: YBColor.white,
                                    child: Padding(
                                      padding: EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20),
                                      child: Column(
                                        mainAxisAlignment: MainAxisAlignment.start,
                                        crossAxisAlignment: CrossAxisAlignment.stretch,
                                        children: [
                                          Container(
                                            child: Text(
                                              YBChineseText.workTaiXuQiuNeiRongTitle,
                                              style: YBTextStyle.TextStyle1B1C1F15Medium,
                                            ),
                                          ),
                                          Container(
                                            height: YBTextStyle.adapterSize15,
                                          ),
                                          Container(
                                            child: Text(
                                              yihuoData.gongGongYouXuanModel.request.requestServiceDesc??"",
                                              style: YBTextStyle.TextStyle6E737A13,
                                            ),
                                          ),
                                          Container(
                                            height: YBTextStyle.adapterSize15,
                                          ),
                                        ],
                                      ),
                                    ),
                                  ),
                                  Container(
                                    height: YBTextStyle.adapterSize8,
                                  ),
                                ],
                              ),
                            ),
                          ),
                          SliverToBoxAdapter(
                            child: Container(
                              color:YBColor.white,
                              child: Padding(
                                padding: EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20,top: YBTextStyle.adapterSize15),
                                child: Text(
                                  YBChineseText.workTaiMishuDetailliuzhuanJiluTitle,
                                  style: YBTextStyle.TextStyle1B1C1F15Medium,
                                ),
                              ),
                            ),
                          ),
                          SliverList(
                            delegate:SliverChildBuilderDelegate((_,int index){
                              YBGongGongCreateTimeModel createTimeModel = yihuoData.gongGongYouXuanModel.requestAssignRecordList[index];
                              return YBMiShuTongListDetailSubPage(numberStr: (index + 1).toString(),timeStr: createTimeModel.createTime,);
                            },
                                childCount: yihuoData.gongGongYouXuanModel.requestAssignRecordList.length
                            ),
                          ),
                        ],
                      ),
                    ),
                    Container(
                      height: YBTextStyle.adapterSize15,
                    ),
                  ],
                );
              }
          ),
        ),
      ),
    );
  }
}
